package org.cyx.javasx.view.abs;

import java.awt.Component;
import org.cyx.javasx.view.IContainer;
import org.cyx.javasx.view.IView;
import org.cyx.javasx.view.ViewContainer;
import java.awt.LayoutManager;

import javax.swing.JFrame;

public abstract class AbsCJFrame extends JFrame implements IContainer {

    protected IContainer container;

    public AbsCJFrame() {
        this(null);
    }

    public AbsCJFrame(IContainer container) {
        this.setContainer(container);
    }

    public void setContainer(IContainer container) {
        if (container == null) {
            container = new ViewContainer(this);
        }
        this.container = container;
    }

    @Override
    public void addView(Component component, LayoutManager layoutManager) {
        this.container.addView(component, layoutManager);
    }

    @Override
    public void updateViewLayout(Component component, LayoutManager layoutManager) {
        this.container.updateViewLayout(component, layoutManager);
    }

    @Override
    public void removeView(Component component) {
        this.container.removeView(component);
    }

    @Override
    public Object findViewById(String id) {
        return this.container.findViewById(id);
    }

    @Override
    public void setId(String id) {
        this.container.setId(id);
    }

    @Override
    public String getId() {
        return this.container.getId();
    }

    @Override
    public Component getOComponent() {
        return this.container.getOComponent();
    }
}